package com.example.payFees.controller;
import com.example.entity.PayFees;
import com.example.payFees.service.PayFeesService;
import com.example.result.CommonResult;
import com.example.utils.MyPageHelper;
import com.example.utils.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/pay")
public class PayFeesController {
    @Autowired
    PayFeesService payFeesService;
    /**
     * 停车场管理-缴费全查
     * @return
     */
    @GetMapping("/getPayFees")
    public CommonResult getPayFees(@RequestParam String payFeesStall, PageRequest pageRequest){
        MyPageHelper.StartPage(pageRequest);
        CommonResult commonResult = payFeesService.getPayFees(payFeesStall);
        return commonResult;
    }
    /**
     * 停车场管理-缴费删除
     */
    @DeleteMapping("/delPayFees")
    public CommonResult delPayFees(Integer id){
        int i = payFeesService.delPayFees(id);
        return CommonResult.ok(i);
    }
    /**
     * 停车场管理-缴费增改
     */
    @PostMapping("/saveOrUpdatePayFees")
    public CommonResult saveOrUpdatePayFees(@RequestBody PayFees payFees){
        int i = payFeesService.saveOrUpdatePayFees(payFees);
        if(i>0){
            return CommonResult.ok();
        }else{
            return CommonResult.fail();
        }
    }
}
